<template>
    <div>
        <el-card class="box-card">
            <div slot="header" class="clearfix">
                <span>消息列表</span>
            </div>
            <el-table :data="form" border size="mini" style="width: 100%">
                <el-table-column
                    label="ID"
                    prop="id"
                    width="320">
                </el-table-column>
                <el-table-column
                    label="消息类型"
                    prop="notifiable_type"
                >
                </el-table-column>
                <el-table-column
                    label="消息ID"
                    prop="notifiable_id"
                    width="360">
                </el-table-column>
                <el-table-column
                    #default="{row:notify}"
                    label="消息内容"
                    width="360">
                    文章ID:{{ notify.data.content_id }}发表标题：{{ notify.data.title }}
                </el-table-column>


                <el-table-column
                    label="创建时间"
                    prop="created_at">
                </el-table-column>
                <el-table-column
                    #default="{row:message}"
                    label="操作">
                    <el-button size="mini" type="primary"
                               @click="read(message)">查看
                    </el-button>
                </el-table-column>
            </el-table>

        </el-card>
    </div>
</template>

<script>
export default {
    data() {
        return {
            form: []
        }
    },
    async created() {
        this.form = await this.axios.get('admin/system/notify')
    },
    methods: {
        async read(message) {
            await this.axios.get(`admin/system/notify/${message.id}`)
            this.$router.push({name: 'admin.content.show', params: {id: message.data.content_id}})
        }
    }

}
</script>

<style scoped>

</style>
